﻿using System;

namespace Sustainalytics.CarbonData.Service
{
    public class PIUpdaterStrings
    {
        public string PI_FRAMEWORK = "PI Framework";
        public string PI_COMPANYASSESSMENTS = "PI Company assessments";
        public string PI_UNIVERSE = "PI Universe";

        public string[] SYMBOLS = { "AE", "AL", "CW", "FA", "FL", "GB", "GM", "MC", "NP", "PE", "TP", "AB", "CO", "SC", "PM", "PP", "AT", "PL", "TC", "AC", "OS" };

        static public PIUpdaterStrings FromConfig()
        {
            var result = new PIUpdaterStrings();
            try
            {
                var symbols = System.Configuration.ConfigurationManager.AppSettings["SYMBOLS"];
                var sheet1 = System.Configuration.ConfigurationManager.AppSettings["INDICATORSHEET"];
                var sheet2 = System.Configuration.ConfigurationManager.AppSettings["COMPANYSHEET"];

                if (!string.IsNullOrEmpty(symbols))
                    result.SYMBOLS = symbols.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (!string.IsNullOrEmpty(sheet1))
                    result.PI_FRAMEWORK = sheet1;

                if (!string.IsNullOrEmpty(sheet2))
                    result.PI_COMPANYASSESSMENTS = sheet2;
            }
            catch (Exception ex)
            {
                Sustainalytics.Utils.ProductInvolvementEventSource.Log.Exception(ex);
            }
            return result;
        }
    }

}
